package com.blue.code.db.bean;

import java.util.List;

import com.blue.code.db.src.Table;
import com.blue.core.util.ReflectionUtil;

public class EntityBean
{
	private String table;
	private String prefix;
	private String clazz;
	private String name;
	private String comment;
	private List<EntityId> idList;
	private List<EntityColumn> columnList;

	public EntityBean()
	{
	}

	public static EntityBean toEntity(Table table)
	{
		EntityBean bean = new EntityBean(table.getTable());
		bean.setClazz(ReflectionUtil.tableToClazz(table.getTable(), table.isPrefix()));
		bean.setPrefix(table.getTable().split("_")[0]);
		bean.setName(table.getName());
		bean.setComment(table.getComment());
		bean.setIdList(EntityId.toId(table.getIdList()));
		bean.setColumnList(EntityColumn.toColumn(table.getColumnList()));
		return bean;
	}

	public EntityBean(String table)
	{
		this.table = table;
	}

	public String getTable()
	{
		return table;
	}

	public void setTable(String table)
	{
		this.table = table;
	}

	public String getPrefix()
	{
		return prefix;
	}

	public void setPrefix(String prefix)
	{
		this.prefix = prefix;
	}

	public String getClazz()
	{
		return clazz;
	}

	public void setClazz(String clazz)
	{
		this.clazz = clazz;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getComment()
	{
		return comment;
	}

	public void setComment(String comment)
	{
		this.comment = comment;
	}

	public List<EntityId> getIdList()
	{
		return idList;
	}

	public void setIdList(List<EntityId> idList)
	{
		this.idList = idList;
	}

	public List<EntityColumn> getColumnList()
	{
		return columnList;
	}

	public void setColumnList(List<EntityColumn> columnList)
	{
		this.columnList = columnList;
	}

}
